home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / drdobbs.zip / WHSTRUCT.H < prev    next >
Text File  |  1993-08-03  |  11KB  |  271 lines

  1. /* Windows Help File Internal Records
  2.    Pete Davis & Ron Burk  -  05/93    */
  3.  
  4. typedef unsigned long   DWORD;
  5. typedef unsigned int    WORD;
  6. typedef unsigned char   BYTE;
  7.  
  8. /* Define WHIFS Page Size and Page size for other B-Trees */
  9. #define WHIFSPageSize 1024L
  10. #define BTreePageSize 2048L
  11.  
  12. /* Define the size of a Topic Block 4k - sizeof(TOPICLINK) */
  13. #define TopicBlockSize 4084L
  14.  
  15.  
  16. #define GotoWHIFSPage(DestPage)     \
  17.     fseek(HelpFile, FirstPageLoc+(DestPage * WHIFSPageSize), SEEK_SET)
  18.  
  19. #define GotoPage(DestPage)          \
  20.     fseek(HelpFile, FirstPageLoc+(DestPage * BTreePageSize), SEEK_SET)
  21.  
  22. #define RGB(r,g,b) ((DWORD)(b*65536) + (DWORD)(g*256) + (DWORD) (r))
  23.  
  24. /* Help file Header record */
  25. typedef struct HELPHEADER {
  26.     DWORD   MagicNumber;      /* 0x00035F3F                */
  27.     long    WHIFS;            /* Pointer to WHIFS header   */
  28.     long    Negative1;
  29.     long    FileSize;         /* Size of entire .HLP File  */
  30. } HELPHEADER;
  31.  
  32.  
  33. /* File Header for WHIFS files */
  34. typedef struct FILEHEADER {
  35.     long    FilePlusHeader;  /* File size including this header */
  36.     long    FileSize;        /* File size not including header  */
  37.     char    TermNull;
  38. } FILEHEADER;
  39.  
  40.  
  41. /* Help Directory BTREE */
  42. typedef struct WHIFSBTREEHEADER {
  43.     char    Magic[18];      /* Not exactly magic for some .MVB files   */
  44.     char    Garbage[13];
  45.     int     MustBeZero;     /* Probably shows up when Help > ~40 megs  */
  46.     int     NSplits;        /* Number of page split Btree has suffered */
  47.     int     RootPage;       /* Page # of root page                     */
  48.     int     MustBeNegOne;   /* Probably shows up when B-Tree is HUGE!! */
  49.     int     TotalPages;     /* total # to 2Kb pages in Btree           */
  50.     int     NLevels;        /* Number of levels in this Btree          */
  51.     DWORD   TotalWHIFSEntries;
  52. } WHIFSBTREEHEADER;
  53.  
  54. /* Keyword & TTL BTREE Headers - Slightly different than WHIFS B-tree Header.
  55.    Both WHIFS and Keyword B-Trees use same leaf and index node headers.    */
  56.  
  57. typedef struct BTREEHEADER {
  58.     char    Unknown1[22];
  59.     int     MustBeZero1;
  60.     int     NSplits;        /* # of page splits Btree has suffered */
  61.     int     RootPage;       /* page #of root page */
  62.     int     MustBeNegOne1;
  63.     int     TotalPages;     /* total # of 2Kb pages in Btree */
  64.     int     NLevels;        /* # of levels in this Btree */
  65.     DWORD   TotalBtreeEntries;
  66. } BTREEHEADER;
  67.  
  68. /* Modified B-Tree Node header to handle a pointer to the page */
  69. typedef struct BTREENODEHEADER {
  70.     WORD    Signature;      /* Signature word            */
  71.     int     NEntries;       /* Number of entries         */
  72.     int     PreviousPage;   /* Index of Previous Page    */
  73.     int     NextPage;       /* Index of Next Page        */
  74. } BTREENODEHEADER;
  75.  
  76. /* Modified B-Tree Index header to handle a pointer to the page */
  77. typedef struct BTREEINDEXHEADER {
  78.     WORD    Signature;      /* Signature byte            */
  79.     int     NEntries;       /* Number of entries in node */
  80. } BTREEINDEXHEADER;
  81.  
  82.  
  83. /* Phrase header In uncompressed, last field is empty */
  84. typedef struct PHRASEHDR    {
  85.     int     NumPhrases;     /* Number of phrases in table                     */
  86.     WORD    OneHundred;     /* 0x0100                                         */
  87.     long    PhrasesSize;    /* Amount of space uncompressed phrases requires. */
  88. } PHRASEHDR;
  89.  
  90.  
  91.  
  92. /* Header for |FONT file */
  93. typedef struct FONTHEADER {
  94.     WORD    NumFonts;           /* Number of fonts in Font List */
  95.     WORD    NumDescriptors;     /* Number of font descriptors   */
  96.     WORD    DefDescriptor;      /* Default font descriptor      */
  97.     WORD    DescriptorsOffset;  /* Offset to descriptor list    */
  98. } FONTHEADER;
  99.  
  100. typedef struct FONTDESCRIPTOR {
  101.     BYTE    Attributes;         /* Font Attributes See values below */
  102.     BYTE    HalfPoints;         /* PointSize * 2                    */
  103.     BYTE    FontFamily;         /* Font Family. See values below    */
  104.     BYTE    FontName;           /* Number of font in Font List      */
  105.     BYTE    Unknown;
  106.     BYTE    FGRGB[3];           /* RGB values of foreground         */
  107.     BYTE    BGRGB[3];           /* background RGB Values (?? Not sure */
  108. } FONTDESCRIPTOR;
  109.  
  110. /* Font Attributes */
  111. #define FONT_NORM    0x00       /* Normal         */
  112. #define FONT_BOLD    0x01       /* Bold           */
  113. #define FONT_ITAL    0x02       /* Italics        */
  114. #define FONT_UNDR    0x04       /* Underline      */
  115. #define FONT_STRK    0x08       /* Strike Through */
  116. #define FONT_DBUN    0x10       /* Dbl Underline  */
  117. #define FONT_SMCP    0x20       /* Small Caps     */
  118.  
  119. /* Font Families */
  120. #define FAM_MODERN   0x01
  121. #define FAM_ROMAN    0x02
  122. #define FAM_SWISS    0x03
  123. #define FAM_TECH     0x03
  124. #define FAM_NIL      0x03
  125. #define FAM_SCRIPT   0x04
  126. #define FAM_DECOR    0x05
  127.  
  128.  
  129. /* Header for |SYSTEM file */
  130. typedef struct SYSTEMHEADER {
  131.     BYTE    Magic;     /* 0x6C                  */
  132.     BYTE    Version;   /* Version #             */
  133.     BYTE    Revision;  /* Revision code         */
  134.     BYTE    Always0;   /* Unknown               */
  135.     WORD    Always1;   /* Always 0x0001         */
  136.     DWORD   GenDate;   /* Date/Time that the help file was generated    */
  137.     WORD    Flags;     /* Values seen: 0x0000 0x0004, 0x0008, 0x000A    */
  138. } SYSTEMHEADER;
  139.  
  140. /* Flags for |SYSTEM header Flags field below */
  141. #define NO_COMPRESSION_310      0x0000
  142. #define COMPRESSION_310         0x0004
  143. #define COMPRESSION_UNKN        0x0008
  144. #define SYSFLAG_300             0x000A
  145.  
  146. /* Help Compiler 3.1 System record. Multiple records possible */
  147. typedef struct SYSTEMREC {
  148.     WORD    RecordType;   /* Type of Data in record      */
  149.     WORD    DataSize;     /* Size of RData               */
  150.     char    *RData;       /* Raw data (Icon, title, etc) */
  151. } SYSTEMREC;
  152.  
  153. /* Types for SYSTEMREC RecordType below */  
  154. #define HPJ_TITLE       0x0001      /* Title from .HPJ file            */
  155. #define HPJ_COPYRIGHT   0x0002      /* Copyright notice from .HPJ file */
  156. #define HPJ_CONTENTS    0x0003      /* Contents=??? from .HPJ          */
  157. #define MACRO_DATA      0x0004      /* SData = 4 nulls if no macros    */
  158. #define ICON_DATA       0x0005
  159. #define HPJ_SECWINDOWS  0x0006      /* Secondary window info in .HPJ   */
  160. #define HPJ_CITATION    0x0008      /* CITATION= under [OPTIONS]       */
  161.  
  162.  
  163. /* Secondary Window Record following type 0x0006 System Record */
  164.  
  165. typedef struct SECWINDOW {
  166.     WORD    Flags;          /* Flags (See Below)        */
  167.     BYTE    Type[10];       /* Type of window           */
  168.     BYTE    Name[9];        /* Window name              */
  169.     BYTE    Caption[51];    /* Caption for window       */
  170.     WORD    X;              /* X coordinate to start at */
  171.     WORD    Y;              /* Y coordinate to start at */
  172.     WORD    Width;          /* Width to create for      */
  173.     WORD    Height;         /* Height to create for     */
  174.     WORD    Maximize;       /* Maximize flag            */
  175.     BYTE    Rgb[3];
  176.     BYTE    Unknown1;
  177.     BYTE    RgbNsr[3];      /* RGB for non scrollable region */
  178.     BYTE    Unknown2;
  179. } SECWINDOW;
  180.  
  181. /** Values for Flags **/
  182.  
  183. #define WSYSFLAG_TYPE       0x0001  /* Type is valid        */
  184. #define WSYSFLAG_NAME       0x0002  /* Name is valid        */
  185. #define WSYSFLAG_CAPTION    0x0004  /* Ccaption is valid    */
  186. #define WSYSFLAG_X          0x0008  /* X    is valid        */
  187. #define WSYSFLAG_Y          0x0010  /* Y    is valid        */
  188. #define WSYSFLAG_WIDTH      0x0020  /* Width    is valid    */
  189. #define WSYSFLAG_HEIGHT     0x0040  /* Height   is valid    */
  190. #define WSYSFLAG_MAXIMIZE   0x0080  /* Maximize is valid    */
  191. #define WSYSFLAG_RGB        0x0100  /* Rgb  is valid        */
  192. #define WSYSFLAG_RGBNSR     0x0200  /* RgbNsr   is valid    */
  193. #define WSYSFLAG_TOP        0x0400  /* On top was set in HPJ file */
  194.  
  195. /* Header for |TOMAP file */
  196. typedef struct TOMAPHEADER {
  197.     long    IndexTopic;   /* Index topic for help file */
  198.     long    Reserved[15];
  199.     int     ToMapLen;     /* Number of topic pointers  */
  200.     long    *TopicPtr;    /* Pointer to all the topics */
  201. } TOMAPHEADER;
  202.  
  203.  
  204.  
  205. /* Keyword Map Record */
  206. typedef struct KWMAPREC {
  207.     long    FirstRec;       /* Index number of first keyword on leaf page    */
  208.     WORD    PageNum;        /* Page number that keywords are associated with */
  209. } KWMAPREC;
  210.  
  211.  
  212. /* |TOPIC Block header - Header for a block of topic data. If
  213. uncompressed, there's only one of these at the beginning of the
  214. file. If the help file is compressed, then these occur in 4k
  215. increments. (e.g. 0x0000, 0x1000, 0x2000, 0x3000, 0x4000, etc. ) */
  216. typedef struct TOPICBLOCKHEADER {
  217.     long    LastTopicLink;   /* Offset of last topic link in previous block   */
  218.     long    TopicData;       /* Offset of topic data start                    */
  219.     long    LastTopicHeader; /* Offset of last topic header in previous block */
  220. } TOPICBLOCKHEADER;
  221.  
  222.  
  223. /* Linked list record for |TOPIC file */
  224. typedef struct TOPICLINK {
  225.     long     BlockSize;   /* Size of this link + Data         */
  226.     long     DataLen2;    /* Length of LinkData2              */
  227.     long     PrevBlock;   /* Relative to first byte of |TOPIC */
  228.     long     NextBlock;   /* Relative to first byte of |TOPIC */
  229.     long     DataLen1;    /* Len(LinkData1 + 11(hdr size))    */
  230.     BYTE     RecordType;  /* See below                        */
  231.     BYTE     *LinkData1;  /* Data associated with this link   */
  232.     BYTE     *LinkData2;  /* Second set of data               */
  233. } TOPICLINK;
  234.  
  235. /* Known record types for topic link */
  236. #define TL_TOPICHDR    0x02  /* Topic header information */
  237. #define TL_DISPLAY     0x20  /* Displayable information  */
  238. #define TL_TABLE       0x23  /* WinHelp Table            */
  239.  
  240. /* Topic header. Starts inside LinkData of a type 0x02 record */
  241. typedef struct TOPICHEADER {
  242.     long     BlockSize; /* Size of topic, including internal topic links  */
  243.     long     BrowseBck; /* Topic offset for prev topic in Browse sequence */
  244.     long     BrowseFor; /* Topic offset for next topic in Browse sequence */
  245.     DWORD    TopicNum;  /* Topic Number(?)                                */
  246.     long     NonScroll; /* Start of Non-Scroll Region                     */
  247.     long     Scroll;    /* Start of Scrolling Region of text.             */
  248.     long     NextTopic; /* Start of next Type 0x02 record                 */
  249. } TOPICHEADER;
  250.  
  251. /* Record from |CTXOMAP file. Created from the [MAP] section of .HPJ file */
  252. typedef struct CTXOMAPREC {
  253.     long     MapID;
  254.     long     TopicOffset;
  255. } CTXOMAPREC;
  256.  
  257.  
  258. /* Record from |CONTEXT file */
  259. typedef struct CONTEXTREC {
  260.     long     HashValue;       /* Hash value of a phrase     */
  261.     long     TopicOffset;     /* Topic offset of the phrase */
  262. } CONTEXTREC;
  263.  
  264. /* Record for the |KWBTREE file */
  265. typedef struct KWBTREEREC {
  266.     char     Keyword[80];     /* Variable Length Keyword      */
  267.     int      Count;           /* Count of Keywords occurances */
  268.     long     KWDataOffset;    /* Offset into |KWDATA file     */
  269. } KWBTREEREC;
  270. 
  271.